﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection.Emit;
using System.Text;
using System.Threading.Tasks;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using SageKing.Database.EF.Entity.Contracts;

namespace SageKing.Database.EF.Entity;

public class TemplateConfiguration : IEntityTypeConfiguration<TemplateBase>
{
    public void Configure(EntityTypeBuilder<TemplateBase> builder)
    {
        // table
        builder.ToTable("Template");

        // columns
        builder.HasKey(x => x.Id);
        builder.Property(x => x.Id).ValueGeneratedOnAdd();      // 启用自增

        builder.HasIndex(x => new { x.TemplateId, x.Name, x.Type }).IsUnique();

        builder.Property(x => x.TemplateId).IsRequired();
        builder.Property(x => x.Name).IsRequired();
    }
}
